package com.zmn.oms.services.impl.operation;

import com.vdurmont.emoji.EmojiParser;
import com.zmn.common.utils.string.StringUtil;
import com.zmn.oms.model.entity.operation.OrderOperation;
import com.zmn.oms.persistence.interfaces.operation.OrderOperationDao;
import com.zmn.oms.services.interfaces.operation.OrderOperationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 类描述：
 *
 * @author lhl
 * @date 2020/01/08 14:39
 */
@Service("orderOperationService")
public class OrderOperationServiceImpl implements OrderOperationService {

    @Resource
    private OrderOperationDao orderOperationDao;

    @Override
    public int insertOrUpdateByKey(OrderOperation orderOperation) {
        return orderOperationDao.insertOrUpdateByKey(orderOperation);
    }

    @Override
    public OrderOperation findBykey(Long orderId) {
        OrderOperation orderOperation = orderOperationDao.findBykey(orderId);

        if (orderOperation != null && StringUtil.isNotBlank(orderOperation.getQuotationName())) {// 表情符号转换为字符
            orderOperation.setQuotationName(EmojiParser.parseToUnicode(orderOperation.getQuotationName()));
        }
        if (orderOperation != null && StringUtil.isNotBlank(orderOperation.getCreater())) {// 表情符号转换为字符
            orderOperation.setCreater(EmojiParser.parseToUnicode(orderOperation.getCreater()));
        }

        return orderOperation;
    }

    @Override
    public List<OrderOperation> listByOrderIdList(List<Long> orderIdList) {
        return orderOperationDao.listByOrderIdList(orderIdList);
    }
}